<html>
<head>
	<meta charset='utf-8' />
	<title>后台管理</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#Content,#Nav_bottom,#Back_Btn{width:98%;margin:0 auto}

			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#Content,#Nav_bottom,#Back_Btn{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
	</style>
</head>
<body style='padding:0;margin:0;background:#eaa'>



	<!-- 1 Content容器 -->
	<div id='Content' >

		<h2 style='color:red;text-align:center'>后台管理登陆</h2>


		<div style='text-indent:80px;'>
			登陆名：<input id='Login_User' style='width:230px'/>
		</div>

		<div style='text-indent:80px;margin:20px auto'>
			密　码：<input id='Login_Pwd' type='password' style='width:230px'/>
		</div>


		<!--div style='text-indent:80px;margin:20px auto'>
			验证码：<input id='Login_Code' style='width:70px'/>
			<img src="interface.php?type=code" align='top' alt="点击" style='width:100px;height:40px' id="Login_Code" onclick="ChangeCode(this)">
		</div-->

		<div style='text-align:center'>
			<button  id='Login_Sub'>登陆</button>
		</div>

	</div><!-- 1 Content容器结束 -->



</body>
</html>




<script src='../Public/jquery.js'></script>
<script src='../Public/fun.js'></script>

<script>

	$('#Login_Sub').click(function(){
		var user = ChangeChar($('#Login_User').val().trim());
		var pwd = ChangeChar($('#Login_Pwd').val().trim());

		if(!user || !pwd){
			A('用户名或密码不得为空！');
		}
		//sessionStorage.currentDomain = 'http:a';

		//检测随机域名
		if(!sessionStorage.currentDomain || !/^http.*$/.test(sessionStorage.currentDomain)){
			if(user != admin_user_name){	//不是超管就跳转到错误页
				location.href='../error.html?t=40001';
				err
			}else{
				sessionStorage.currentDomain = default_domain;
			}
		}

		//检测开通城市数据
		if(!localStorage.openCity || !/^{"openCity".*}$/.test(localStorage.openCity)){
			if(user != admin_user_name){	//不是超管就跳转到错误页
				location.href='../error.html?t=40002';
				err
			}
		}

		//Field_Check(/^[a-z]\w{4,19}$/,user,'登陆名非法!');

		
		//拼接请求地址
		sessionStorage.admin_requestAddr = sessionStorage.currentDomain + default_requestPath;






		var data = {
			user:user,
			pwd:pwd,
			type:'AdminLogin'
		};
		AjaxAdmin(data,function(res){
			
			var tmp = _checkJsonFormat(res); //检测JSON格式
			if(tmp.stat == 'ok'){
				var cityList = JSON.parse(localStorage.openCity).openCity;
				sessionStorage.admin_user_info = JSON.stringify(tmp.data);
				if(user == 'a'){	//超管
					sessionStorage.openCity = JSON.stringify(cityList);
					location.href = 'main.html';
				}else{				//普管
					var userCityList = JSON.parse(tmp.data.code_list);

					if(typeof(userCityList) !='object' || userCityList.length < 1){
						A('暂无权限！');return;
					}

					//给有权限的城市标记状态
					for(var i=0;i<userCityList.length;i++){
						for(var s=0;s<cityList.length;s++){
							for(var c=0;c<cityList[s].city.length;c++){
								for(var x=0;x<cityList[s].city[c].county.length;x++){
									if(userCityList[i] == cityList[s].city[c].county[x].code){
										cityList[s].stat = 1;
										cityList[s].city[c].stat = 1;
										cityList[s].city[c].county[x].stat = 1;
									}
								}
							}
						}
					}

					//根据标记筛选开通城市
					var cityList2 = [];	//筛选省
					for(var s=0;s<cityList.length;s++){
						if(cityList[s].stat){
							cityList2.push(cityList[s]);
						}
					}

					for(var s=0;s<cityList2.length;s++){
						var tmpCity = [];
						for(var c=0;c<cityList2[s].city.length;c++){
							if(cityList[s].city[c].stat){
								tmpCity.push(cityList[s].city[c]);
							}
						}
						cityList2[s].city = tmpCity;
					}
					for(var s=0;s<cityList2.length;s++){
						for(var c=0;c<cityList2[s].city.length;c++){
							var tmpConty = [];
							for(var x=0;x<cityList2[s].city[c].county.length;x++){
								if(cityList2[s].city[c].county[x].stat){
									tmpConty.push(cityList2[s].city[c].county[x]);
								}
							}
							cityList2[s].city[c].county = tmpConty;
						}
					}
					sessionStorage.openCity = JSON.stringify(cityList2);
					location.href = 'city.html';
				}
			}else{
				A('用户名或密码不正确！');
			}
		});
	});

</script>










